<?php

require '../vendor/autoload.php';

use Firebase\JWT\JWT;
use Firebase\JWT\Key;
		
$key = 'example_key';
$payload = [
    'iss' => 'admin', //签发者
    'aud' => 'http://example.com',
    'iat' => time(),   //什么时候签发的
    'exp' => time()+3600  	//过期时间
];

/**
 * IMPORTANT:
 * You must specify supported algorithms for your application. See
 * https://tools.ietf.org/html/draft-ietf-jose-json-web-algorithms-40
 * for a list of spec-compliant algorithms.
 */
$jwt = JWT::encode($payload, $key, 'HS256');
$decoded = JWT::decode($jwt, new Key($key, 'HS256'));

print_r($jwt);
echo "<hr>";


print_r($decoded);
print_r($decoded->iss);
?>